﻿using System;
using System.Windows.Forms;
using AsyncLibrary.StatusListener;

namespace AsyncLibrary.UI
{
  public partial class StatusForm : Form, IStatusListener
  {
    public StatusForm()
    {
      InitializeComponent();
    }

    public void SetProgress(int value)
    {
      _progressBar.Value = value;
    }

    public void SetProgresMax(int value)
    {
      _progressBar.Maximum = value;
    }

    public void SetMode(StatusProgressMode value)
    {
      switch (value)
      {
        case StatusProgressMode.Progress:
          _progressBar.Style = ProgressBarStyle.Continuous;
          break;
        case StatusProgressMode.Infinity:
          _progressBar.Style = ProgressBarStyle.Marquee;
          break;
        default:
          throw new ArgumentOutOfRangeException("value");
      }
    }

    public void SetStatus(string message)
    {
      Text = message;
    }

    public void SetInfo(string text)
    {
      _infoLabel.Text = text;
    }

    public void FatalError(Exception ex)
    {
    }
  }
}
